package com.cn.admin;


import com.cn.admin.controller.CouponController;
import com.cn.admin.vo.coupon.CouponVO;
import com.cn.admin.vo.coupon.TrackVO;
import com.cn.common.result.Result;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Coupon {
        @Resource
        private CouponController couponController;

    @Test
    public void test() throws IOException {
        CouponVO couponVO = new CouponVO();
        Result<List<CouponVO>> allCoupon = couponController.findAllCoupon(couponVO);
        System.out.println(allCoupon);
    }

    @Test
    public void test1() {
        Result<CouponVO> byId = couponController.findById(3);
        System.out.println(byId);
    }

    @Test
    public void test2() throws IOException {
        Result<CouponVO> byStatus = couponController.findByStatus(0);
        System.out.println(byStatus);
    }

    @Test
    public void test3() throws IOException {
        CouponVO couponVO = new CouponVO();
        BigDecimal bigDecimal = new BigDecimal("60");
        couponVO.setCoupon_id(1009);
        couponVO.setImg("的点点滴滴多 ");
        couponVO.setName("儿童节欢乐送");
        couponVO.setType("折扣券");
        couponVO.setCount(200);
        couponVO.setStatus(0);
        couponVO.setCreate_time("2022-01-02 08:00:00");
        couponVO.setUpdate_time("2022-02-28 00:00:00");
        couponVO.setStart_time("2022-02-28 00:00:00");
        couponVO.setEnd_time("2022-02-28 00:00:00");
        couponVO.setCoupon_amount(bigDecimal);
        couponVO.setExplain("每人限领一次，优惠券不可叠加使用，不可转增他人");
        couponVO.setEffective_time("2022-06-1 00:00:00——2022-06-07 23:59:59");

        Result<CouponVO> coupon = couponController.createCoupon(couponVO);
        System.out.println(coupon);
    }

    @Test
    public void test4() throws IOException {
        CouponVO couponVO = new CouponVO();
        BigDecimal bigDecimal = new BigDecimal("60");
        couponVO.setId(3);
        couponVO.setImg(" 呵呵哈哈哈");
        couponVO.setName("双十一购物狂欢");
        couponVO.setType("折扣券");
        couponVO.setCount(200);
        couponVO.setStart_time("2022-02-28 00:00:00");
        couponVO.setEnd_time("2022-02-28 00:00:00");
        couponVO.setCoupon_amount(bigDecimal);
        couponVO.setExplain("每人限领一次，优惠券不可叠加使用，不可转增他人");
        couponVO.setEffective_time("2022-06-1 00:00:00——2022-06-07 23:59:59");
        Result result = couponController.editCoupon(couponVO);
        System.out.println(result);
    }

    @Test
    public void test5() throws IOException {
        Result result = couponController.deleteCoupon(5);
        System.out.println(result);
    }

    @Test
    public void test6() throws IOException {
        Result enable = couponController.enable(1);
        System.out.println(enable);
    }

    @Test
    public void test7() throws IOException {
        TrackVO trackVO = new TrackVO();
        Result<List<TrackVO>> allDetailed = couponController.findAllDetailed(trackVO);
        System.out.println(allDetailed);
    }

    @Test
    public void test8() throws IOException {
        Result<TrackVO> byNumber = couponController.findByNumber("20220201555666888");
        System.out.println(byNumber);
    }

    @Test
    public void test9() throws IOException {
        Result<TrackVO> byState = couponController.findByState(0);
        System.out.println(byState);
    }
}
